import request from '@/utils/request'
// import qs from 'qs'

/**
 * 系统设置-部门管理-获取部门列表
 * url:'/system/dept/list'
 * method:GET
 * @Header Authorization: 登录接口返回的token
 * @Query params:{
    page: 1, // 当前页数
    size: 20, // 每页个数
    deptName: undefined,
    status: undefined
 * }
 * @returns {*}
 */
export const getDepartmentListAPI = (params = {}) => {
  return request.get('/system/dept/list', {
    params
  })
}

/**
 * 系统设置-部门管理-查询部门详细
 * url:'/system/dept/${id}'
 * method:GET
 * @Header Authorization: 登录接口返回的token
 * @Query params:{
 *   deptId: ''
 * }
 * @returns {*}
 */
export const getDepartmentDetailAPI = (params = {}) => {
  return request.get(`/system/dept/${params.deptId}`, {
    params
  })
}

/**
 * 系统设置-部门管理-查询部门下拉树结构
 * url:'/system/dept/treeselect'
 * method:GET
 * @Header Authorization: 登录接口返回的token
 * @Query params:{}
 * @returns {*}
 */
export const getDepartmentAllListAPI = (params = {}) => {
  return request.get('/system/dept/treeselect', {
    params
  })
}

/**
 * 系统设置-部门管理-添加部门
 * url:'/system/dept'
 * method:POST
 * @Header Authorization: 登录接口返回的token
 * @Query params:{
    parentId: 212
    deptName: "测试123"
    orderNum: 1
    chargeUserId: 102
    assistantUserId: 106
    phone: "18761111111"
    email: "123@qq.com"
    status: "0"
 * }
 * @returns {*}
 */
export const createDepartmentAPI = (params = {}) => {
  return request.post('/system/dept', params)
}

/**
 * 系统设置-部门管理-修改部门
 * url:'/system/dept'
 * method:POST
 * @Header Authorization: 登录接口返回的token
 * @Query params:{
    id: '',
    parentId: 212
    deptName: "测试123"
    orderNum: 1
    chargeUserId: 102
    assistantUserId: 106
    phone: "18761111111"
    email: "123@qq.com"
    status: "0"
 * }
 * @returns {*}
 */
export const updateDepartmentAPI = (params = {}) => {
  return request.put('/system/dept', params)
}

/**
 * 系统设置-部门管理-删除部门
 * url:'/system/dept/${ids}'
 * method:POST
 * @Header Authorization: 登录接口返回的token
 * @Query params:{
    ids: []
 * }
 * @returns {*}
 */
export const deleteDepartmentAPI = (params = {}) => {
  let { ids = [] } = params
  return request.delete(`/system/dept/${ids.join(',')}`, {})
}

/**
 * 系统设置-部门管理-获取负责人列表
 * url: '/system/dept/leaderList/${type}'
 * method:GET
 * @Header Authorization: 登录接口返回的token
 * @Query params:{
    type: '' // 负责人： SYS_CHARGE 助理：SYS_ASSISTANT
 * }
 * @returns {*}
 */
export const getDepartmentLeaderList = (params = {}) => {
  return request({
    method: 'get',
    url: `/system/dept/leaderList/${params.type}`
  })
}

/**
 * 系统设置-部门管理-导出
 * url:'/api/dept/export'
 * method:GET
 * @Header Authorization: 登录接口返回的token
 * @Query params:{
    sort: 'id,desc'
 * }
 * @returns {*}
 */
export const exportDepartmentListAPI = (params = {}) => {
  return request({
    method: 'get',
    url: '/api/dept/export',
    responseType: 'blob',
    params
  })
}
